package com.example.algorithmdemo.queue;

import java.util.Stack;

/**
 * 队列
 */
public class Queue {
    private Stack<Integer> popStack = new Stack<Integer>();
    private Stack<Integer> pushStack = new Stack<Integer>();
    public Integer popQueue(){
        while (!pushStack.empty()){
            popStack.push(pushStack.pop());
        }
        Integer popElement = popStack.pop();
        while (!popStack.isEmpty()){
            pushStack.push(popStack.pop());
        }
        return popElement;
    }
    public void pushQueue(Integer element){
        pushStack.push(element);
    }

    public final class testTwoStackImplentQueue{
        public void  test(){
            Queue queue = new Queue();
            queue.pushQueue(1);
            queue.pushQueue(2);
            queue.pushQueue(3);
            queue.pushQueue(4);
            queue.pushQueue(5);

           Integer element = queue.popQueue();
           System.out.print(element);//1
        }

    }
}
